﻿<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1">
		<!-- Google Chrome Frame也可以让IE用上Chrome的引擎: -->
		<meta name="renderer" content="webkit">
		<!--国产浏览器高速模式-->
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<meta name="author" content="穷在闹市" />
		<!-- 作者 -->
		<meta name="revised" content="穷在闹市.v3, 2019/05/01" />
		<!-- 定义页面的最新版本 -->
		<meta name="description" content="网站简介" />
		<!-- 网站简介 -->
		<meta name="keywords" content="搜索关键字，以半角英文逗号隔开" />

		<!-- 公共样式 开始 -->
		<link rel="stylesheet" type="text/css" href="../../css/base.css">
		<link rel="stylesheet" type="text/css" href="../../css/iconfont.css">
		<script type="text/javascript" src="../../framework/jquery-1.11.3.min.js"></script>
		<link rel="stylesheet" type="text/css" href="../../layui/css/layui.css">
		<script type="text/javascript" src="../../layui/layui.js"></script>
		<!-- 滚动条插件 -->
		<link rel="stylesheet" type="text/css" href="../../css/jquery.mCustomScrollbar.css">
		<script src="../../framework/jquery-ui-1.10.4.min.js"></script>
		<script src="../../framework/jquery.mousewheel.min.js"></script>
		<script src="../../framework/jquery.mCustomScrollbar.min.js"></script>
		<script src="../../framework/cframe.js"></script><!-- 仅供所有子页面使用 -->
		<!-- 公共样式 结束 -->
		
		<style>
			.layui-form{
				margin-right: 30%;
			}
		</style>

	</head>

	<body>
		<div class="cBody">
			<form id="addForm" class="layui-form" action="">
				<div class="layui-form-item">
					<label class="layui-form-label">身份证号</label>
					<div class="layui-input-inline shortInput">
						<input id="identityCardNo" type="text" name="identityCardNo" required lay-verify="required|identity" autocomplete="off" class="layui-input">
					</div>
				</div>
				
				<div class="layui-form-item">
					<label class="layui-form-label">登录名</label>
					<div class="layui-input-inline shortInput">
						<input id="adminName" type="text" name="adminName" required lay-verify="required|ZHCheck" placeholder="(只允许输入中文)" autocomplete="off" class="layui-input">
					</div>
            		<i class="iconfont icon-huaban bt"></i>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">地区</label>
	                <div class="layui-input-inline">
	                    <select name="provid" id="provid" lay-filter="provid">
	                    </select>
	                </div>
	                <div class="layui-input-inline">
	                    <select name="cityid" id="cityid" lay-filter="cityid">
	                        <option value="">请选择市</option>
	                    </select>
	                </div>

					<div class="layui-input-inline">
						<select name="areaid" id="areaid" lay-filter="areaid">
							<option value="">请选择县</option>
						</select>
					</div>

				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">负责人</label>
					<div class="layui-input-inline shortInput">
						<input id="loginName"  name="loginName" required lay-verify="required|ZHCheck" placeholder="例:张三(只允许输入中文)" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">工号</label>
					<div class="layui-input-inline shortInput" id="gonghao">
						<input type="text" id="round2"  autocomplete="off" class="layui-input" readonly/>
						<span ><button onclick="clickMath()">点击生成工号</button></span>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">登录密码</label>
					<div class="layui-input-inline shortInput">
						<input type="password" name="password" autocomplete="off" class="layui-input" value="00000000" readonly>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">职务类型</label>
					<div class="layui-input-inline shortInput">
						<select name="type" id="type" lay-filter="type">
							<option value="0">请选择职务</option>
							<option value="1">实施</option>
							<option value="2">仓管</option>
							<option value="3">维修</option>
						</select>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">电话</label>
					<div class="layui-input-inline shortInput">
						<input id="mobilePhone"  name="mobilePhone" required lay-verify="required|phone" placeholder="例：13000000000" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">邮箱</label>
					<div class="layui-input-inline shortInput">
						<input id="adminEmail" type="text" name="adminEmail" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item layui-form-text">
					<label class="layui-form-label">备注</label>
					<div class="layui-input-block">
						<textarea id="other2" name="other2" placeholder="请输入内容" class="layui-textarea"></textarea>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn" lay-submit lay-filter="submitBut" id="tjBtn">立即提交</button>
						<button type="reset" class="layui-btn layui-btn-primary">重置</button>
					</div>
				</div>
			</form>
			
			<!-- 三级省市 插件 -->
    		<script src="../../framework/area.js"></script>
			<script src="../../framework/province.js"></script>
			<script>
				//默认城市为： 江苏- 徐州- 鼓楼区
		        var defaults = {
		            s1: 'provid',
		            s2: 'cityid',
		            s3: 'areaid',
		            v1: 320000,
		            v2: 320300,
		            v3: 320302
		        };

		        //生成19+6位随机工号
                function clickMath(){
                    var round2 = '19';
                    for (var i = 0; i < 6; i++) {
                        round2+=Math.round(Math.random()*10);
                    }
                    document.getElementById("round2").value = round2;
                }

                //提交新增
                $("#tjBtn").click(function() {
                    //表单验证
                    //非空
                    if ($("#identityCardNo").val() == "") {
                        alert("身份证号不能为空");
                        return;
                    }
                    if ($("#adminName").val() == "") {
                        alert("登录名不能为空");
                        return;
                    }
                    if ($("#loginName").val() == "") {
                        alert("负责人不能为空");
                        return;
                    }
                    if ($("#mobilePhone").val() == "") {
                        alert("电话不能为空");
                        return;
                    }
                    if ($("#adminEmail").val() == "") {
                        alert("邮箱不能为空");
                        return;
                    }

                    if ($("#type").val() == "0") {
                        alert("请选择职务");
                        return;
                    }

                })
                    //格式
                    var email_reg = /^\w+@[0-9a-zA-Z]{2,}(\.[a-z]{2,3}){1,2}$/;
                    if (email_reg.test($("#adminEmail").val()) == false) {
                        alert("邮箱格式不正确");
                    }



                var params = $("form").serialize();
                $.post("/admin/saveNew.json", params, function (data) {
                    if(data>0){
                        location="/agent_list.html?flag=add_success";
                    }else{
                        alert("新增失败");
                    }
                });



			</script>

		</div>
	</body>

</html>